<template>
    <div class="novel-container">
        <el-card style="width: 60%">
            <div slot="header" class="novel-header">
                <span class="chapter-title">{{ novel.chapter }}</span>
            </div>

            <div class="novel-text">
                <p v-for="(paragraph, index) in novel.paragraphs" :key="index">{{ paragraph }}</p>
            </div>
        </el-card>
    </div>
</template>

<script>
export default {
    name: "Nerong",
    data() {
        return {
            novel: {}
        };
    },
    mounted() {
        const storedNovel = JSON.parse(localStorage.getItem('novel'));
        if (storedNovel) {
            // 假设小说内容是一个长字符串，将其按段落分割
            const paragraphs = storedNovel.text.split(' ');
            this.novel = { ...storedNovel, paragraphs };
        }
    }
};
</script>

<style scoped>
.novel-container {
    margin-top: 5%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.novel-header {
    text-align: center;
}

.chapter-title {
    font-size: 1.5em;
    font-weight: bold;
}

.novel-text {
    padding: 20px;
    line-height: 1.6;
    font-size: 1.1em;
}

.novel-text p {
    margin-bottom: 1em;
    text-indent: 2em; /* 设置首行缩进 */
}
</style>